package com.cheyunkeji.er.adapter.fastevaluate;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.activity.fast_evaluate.VehicleLicenseDatePickActivity;
import com.cheyunkeji.er.adapter.MyBaseAdapter;
import com.cheyunkeji.er.view.fast_evaluate.YearAndMonthPickerView;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/** Created by Michael on 2017/3/31 14:19. */
public class PalateLicenseDatePickerAdapter extends MyBaseAdapter {

  public PalateLicenseDatePickerAdapter(ArrayList<String> dataList, Context context) {
    super(dataList, context);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;
    if (convertView == null) {
      convertView =
          LayoutInflater.from(context).inflate(R.layout.er_palate_date_lv_item, parent, false);
      holder = new ViewHolder(convertView);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    String year = (String) dataList.get(position) + context.getString(R.string.year);
    holder.ymPickerView.setClearOthersCheckListener((VehicleLicenseDatePickActivity) context);
    holder.ymPickerView.setTitle(year);
    holder.ymPickerView.setAttachedListItemPosition(position);
    return convertView;
  }

  static class ViewHolder {

    @BindView(R.id.ym_picker_view)
    YearAndMonthPickerView ymPickerView;

    ViewHolder(View view) {
      ButterKnife.bind(this, view);
    }
  }
}
